package gw.com.jni.library.terminal;

import android.os.Handler;

import java.util.HashMap;

/**
 * Created by reeta.zou on 2016/7/1.
 * 跟jni连接的回调类
 */
public abstract class DataListener {

    public static HashMap<String,Handler> jniCallbackHandlerList = new HashMap<>();

    public DataListener() {

    }

    public static DataListener instance = null;

    public void addJniCallBackHandler(String key , Handler mHandler){
        if(key != null && mHandler != null) {
            System.out.println("addJniCallBackHandler key="+key);
            jniCallbackHandlerList.put(key, mHandler);
        }
    }

    public void removeJniCallBackHandler(String key){
        System.out.println("removeJniCallBackHandler key= "+key);
        jniCallbackHandlerList.remove(key);
    }

    public Handler getHandler(String key){
        if(jniCallbackHandlerList.containsKey(key)){
//            System.out.println("getJniCallBackHandler key = "+key);
            return jniCallbackHandlerList.get(key);
        }
//        System.out.println("getJniCallBackHandler 为空 = "+key);
        return null;
    }

    /**
     * http请求返回的回调结果处理
     * @param cmd
     * @param iNotification
     * @param object
     * @param iValue
     */
    public abstract void onServerResponse(int cmd, int iNotification, int iValue, String object);

	/**
	 * K线图、分时图数据返回的回调结果处理
	 * @param cmd
     * @param iNotification
	 * @param obj
	 * @param iValue
	 */
    public abstract void onServerResponse(int cmd, int iNotification, Object obj, int iValue, int uSeq);

}
